package net.steam.easyjoboa.biz.impl;

import java.util.List;

import net.steam.easyjoboa.biz.VoteDetailBiz;
import net.steam.easyjoboa.dao.EmployeeDao;
import net.steam.easyjoboa.dao.VoteDetailDao;
import net.steam.easyjoboa.entity.Employee;
import net.steam.easyjoboa.entity.PageBean;
import net.steam.easyjoboa.entity.VoteDetail;

public class VoteDetailBizImpl implements VoteDetailBiz {

	private VoteDetailDao voteDetailDao;
	
	public List<VoteDetail> getVoteDetail(int id,int voteId) {
		String hql ="from VoteDetail where employee.userId="+id+" and vote.voteId="+voteId;
		List<VoteDetail> list = voteDetailDao.find(hql);
		return list;
	}

	public void addVoteDetail(VoteDetail voteDetail) {
		try {
			voteDetailDao.addEntity(voteDetail);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void updateVoteDetail(VoteDetail voteDetail) {
		voteDetailDao.updateEntity(voteDetail);
	}

	public VoteDetail getVoteDetailById(int id) {
		return voteDetailDao.findById(id);
	}	

	public List<VoteDetail> getVoteDetailsByVoteId(int id) {
		String hql ="from VoteDetail where vote.voteId="+id+"order by voteCount desc";
		return voteDetailDao.find(hql);
	}
	
	

	public void setVoteDetailDao(VoteDetailDao voteDetailDao) {
		this.voteDetailDao = voteDetailDao;
	}

}
